package cate.common.table.show.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.d.GDBlog;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("激活道具")
public class ActiveItemRow extends ERow {

    @NoteField("道具ID")
    public int itemId;

    @NoteField("饰品类型")
    public byte decorateType;

    @NoteField("饰品ID")
    private String decorateTidStr;

    @NoteField("有效时间")
    private long effectiveTime;

    @NoteField("重复使用返还")
    public String backRwdStr;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("道具ID", -1);
        this.itemId = xrw.getInteger("道具ID", 0);
        this.decorateType = xrw.getByte("饰品类型", GDBlog.DecorateType.HEAD_ICON);
        this.decorateTidStr = xrw.getString("饰品ID");
        this.effectiveTime = xrw.getInteger("有效时间",-1);
        this.backRwdStr = xrw.getString("重复使用返还");
    }

    @NoteField(value = "有效时间",detail = "毫秒")
    public long valiedTime;

    @NoteField("激活的饰品id们")
    public List<Integer> decorateTids;

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(decorateTidStr)) {
            decorateTids = Str.strArr2intList(decorateTidStr.split("#"));
        }
        if (effectiveTime > 0) {
            valiedTime = 1000 * effectiveTime;
        } else {
            valiedTime = -1;
        }
    }
}
